home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
eignval
< prev
next >
Wrap
Text File
|
1995-03-31
|
5KB
|
169 lines
Article 3024 of comp.sys.handhelds:
Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!orstcs!usenet!jacobsd
From: jacobsd@usenet@scion.CS.ORST.EDU (Dana Jacobsen)
Newsgroups: comp.sys.handhelds
Subject: Re: Eigenvalues
Message-ID: <1990Dec22.002458.26290@usenet@scion.CS.ORST.EDU>
Date: 22 Dec 90 00:24:58 GMT
References: <9012201714.AA26392@CS.ORST.EDU>
Organization: Oregon State University, Computer Science Dept
Lines: 155
In <9012201714.AA26392@CS.ORST.EDU> john%solvint@orstcs.UUCP writes:
>> Someone posted a message containing the program
>> \<<A I L * - DET \>> (where I = Identity matrix)
>> for finding the characteristic polynomial of a matrrix A.
>> I can't make it work because the 48 doesn't seem to permit
>> symbolic entries in arrayse, as was also the case with the 28s
>> Can someone give me the reference to this message?
>> Thanks...jim_wendel@ub.cc.umich.edu or jwendel@isdmnl.wr.usgs.gov
>>
>>
>Symbollic entries in arrays is not the point.
>One uses this program by making it the current SOLVER equation, putting a square
>array in 'A', the square identity in 'I' and solving for 'L', the eigenvalue.
>This program looks like it was taken from the "Easy Course in Using the HP-28S"
>where it was used to solve for the eigenvalues of matrix 'A', but since the 28
>doesn't have the lambda character, L was used instead.
The HP-28 solution book "Matrices & Vectors" has a more elegant solution that
is probably faster and works better in that you don't have to call the solver.
I wrote a plug-and-chug program around this. Enter the matrix, press the key,
and you get back the eigenvalues.
It works by finding the characteristic polynomial, then solving for that.
I posted this a while ago, but some peopl seem to have missed it, and I also
left out the root-finding programs. This program needs some way of solving an
arbitrary degree polynomial. The program "BAIRS" which came by the net a
while back seems to do the job well. I don't remember who wrote this though
(Wayne Scott?).
All the programs are available via anonymous FTP from scion.cs.orst.edu
(128.193.32.25):~ftp/pub/jacobsd/{hp.eig,hp.proot}.
%%HP: T(3)A(R)F(.);
EIGVAL
\<< DUP DUP
SIZE 1 GET \-> t g n
\<< { } 1 n
START 0
1 n
FOR i
t i DUP 2 \->LIST GET
+
NEXT
1 \->LIST + 't' g
STO*
NEXT \->
b
\<< { 1 }
1 n
FOR i
\-> s
\<< 0 1 i
FOR j b j GET s i
j - 1 + GET * -
NEXT i / 1 \->LIST
s SWAP +
\>>
NEXT
\>>
\>> PROOT
\>>
This is my eigenvalue program. PROOT is a program that will solve f(x)=0
for a polynomial. It takes a list of numbers which are coefficients for the
polynomial (i.e. "4 * x^2 + 3 * x - 3" would be { 4 3 -2 } ). Programs for
this are available on the net, or I could send mine to you. (Or you can
anonymous ftp it from scion.cs.orst.edu:pub/jacobsd/proot & math) The
files aren't in great shape (^M's at the end of each line) but it's there.
Start: An n x n matrix in level 1
Stop: n real or complex values on the stack. These are the
eigenvalues.
%%HP: T(3)A(R)F(.);
PROOT
\<< DUP SIZE \-> n
\<<
IF n 3 >
THEN DUP { HOME
MATH POLY BAIRS }
RCL EVAL SWAP OVER
{ HOME MATH POLY
PDIV } RCL EVAL
DROP2 \-> a b
\<< a PROOT b
PROOT
\>>
ELSE
IF n 2 >
THEN { HOME
MATH POLY QUD } RCL
EVAL
ELSE LIST\->
DROP NEG SWAP /
END
END
\>>
\>>
BAIRS
\<< LIST\-> 1 1
\-> n R S
\<<
DO 0 n
1 + PICK 0 0 0 4
PICK 5 n + 7
FOR J
J PICK R 7 PICK * +
S 8 PICK * + 7 ROLL
DROP DUP 6 ROLLD R
3 PICK * + S 4 PICK
* + 5 ROLL DROP -1
STEP
3 PICK SQ 3 PICK 6
PICK * -
IF
DUP 0 ==
THEN
DROP 1 1
ELSE
6 PICK 6 PICK * 5
PICK 9 PICK * -
OVER / 4 PICK 9
PICK * 8 PICK 7
PICK * - ROT /
END
DUP 'S' STO+ SWAP
DUP 'R' STO+
UNTIL
R\->C ABS .000000001
< 7 ROLLD 6 DROPN
END n
DROPN 1 R NEG S NEG
3 \->LIST
\>>
\>>
QUD
\<< LIST\->
\->ARRY DUP 1 GET /
ARRY\-> DROP ROT DROP
SWAP 2 / NEG DUP SQ
ROT - \v/ DUP2 + 3
ROLLD -
\>>
That's it. Hope everything works fine -- I don't have a cable to transfer
the stuff, so got a friend to do the transfer..
--
Dana Jacobsen Oregon State University
jacobsd@cs.orst.edu Computer Science
..!hplabs!hp-pcd!orstcs!jacobsd
Dana_Jacobsen@RPITSMTS.BITNET `Once a daemon, always a daemon'